package com.xbongbong.saas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 列表操作
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/3/5 11:09
 * @since v1.0
 */
@Getter
public enum ListOptionEnum {
    //
    OPTION("option_0","enum.listOption.attrName.option"),

    FOCUS("option_1","enum.listOption.attrName.focus"),

    REMIND("option_2","enum.listOption.attrName.remind"),

    CALL("option_3","enum.listOption.attrName.call"),

    FLOW("option_4","enum.listOption.attrName.flow"),

    WAIT_PURCHASE_CONTRACT("option_5","enum.listOption.attrName.wait_purchase_contract"),

    WAIT_PURCHASE_PRODUCT("option_6","enum.listOption.attrName.wait_purchase_product"),
    // 库存查询列表页前面的下拉，没有显示名称
    MULTI_SPEC("option_7","enum.listOption.attrName.multi_spec"),

    WAIT_INSTOCK_PRODUCT("option_8","enum.listOption.attrName.wait_instock_product"),

    WAIT_OUTSTOCK_PRODUCT("option_9","enum.listOption.attrName.wait_outstock_product"),

    WAIT_PRODUCE_CONTRACT("option_10","enum.listOption.attrName.wait_produce_contract"),

    WAIT_PRODUCE_PRODUCT("option_11","enum.listOption.attrName.wait_produce_product"),

    STOCK_SEARCH("option_12","enum.listOption.attrName.stock_search"),

    WARNING_SEARCH("option_13","enum.listOption.attrName.warning_search"),

    GUARANTEE_SEARCH("option_14","enum.listOption.attrName.guarantee_search"),

    OVER_LIMIT_NUM("option_15","enum.listOption.attrName.over_limit_num"),

    ACCOUNT_ENABLE("option_16","enum.fieldType.description.option"),
    ;
    private String attr;
    private String attrName;

    ListOptionEnum(String attr, String attrName) {
        this.attr = attr;
        this.attrName = attrName;
    }

    public String getAttrName() {
        return I18nMessageUtil.getMessage(attrName);
    }

    public static ListOptionEnum getByAttr(String attr) {
        for (ListOptionEnum cacheCode : values()) {
            if (cacheCode.getAttr().equals(attr)) {
                return cacheCode;
            }
        }
        return null;
    }
}
